﻿using dz.util.core;
using Dz.WorkerService.jkyschema;
using Dz.WorkerService.QueryParm;

namespace Dz.WorkerService
{
    public class PackageListCount
    {
        public async Task<int>  GetCnt()
        {
            PackageListCountParm parm  = new PackageListCountParm();
            WebResult result = await JkyUtils.Post("erp-goods.goods.listCountGoodspackage", JsonUtil.Serialize(parm));

            #region 判断http请求是否成功
            if (!result.Sucess)
                if (!result.Sucess)
                {
                    throw new Exception("获取组合包装数量出错");
                }
            #endregion

            #region 判断请求结构是否成功
            JkyResult result1 = JsonUtil.Deserialize<JkyResult>(result.Data);
            if (result1.code != 200)
            {
                throw new Exception($"获取组合包装数量出错：{result1.msg}");
            }
            #endregion

            #region 处理请求结果
            PackageCountResult result2 = JsonUtil.Deserialize<PackageCountResult>(result1.result.ToString());

            return result2.data;
            #endregion


        }
    }
}
